const mongoose = require('mongoose');
const messageSchema = new mongoose.Schema({
  //关联会话
  sessionId:{type:mongoose.Schema.Types.ObjectId,ref: 'Session', required: true },
  //发送方
  senderType:{type:String,enum:['User','Admin'],required: true},
  senderId:{type:mongoose.Schema.Types.ObjectId,required: true },
  //接收方
  receiverType:{type:String,enum:['User','Admin'],required: true},
  receiverId:{type:mongoose.Schema.Types.ObjectId,required: true },
  //具体消息
  content:{type:String},
  //发送时间
  sendTime:{type:Date,default: Date.now},
  isRead:{type:Boolean}
});

module.exports = mongoose.model('Message', messageSchema);